package com.logos.ruralrevitalization.controller;

import com.logos.ruralrevitalization.req.ChatReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import javax.annotation.Resource;

@RestController
@RequestMapping("/ai")
@Slf4j
public class ChatController {
    @Resource(name = "touristChatClient")
    private ChatClient chatClient;

    @PostMapping(value = "/test",produces = "text/html;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatReq chatReq) {
        return chatClient.prompt()
                .user(chatReq.getMessage())
                .stream()
                .content();
    }
}